package com.zhiyou100.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.zhiyou100.dao.UserDAO;
import com.zhiyou100.model.User;
@Repository("userDAO")
public class UserDAOImpl implements UserDAO{
	
	@Autowired
	HibernateTemplate hibernateTemplate;
	
	public void add(User e) {
		hibernateTemplate.save(e);
		
	}

	public void update(User e) {
		hibernateTemplate.update(e);
		
	}

	public void deleteById(int id) {
		User user = new User();
		user.setId(id);
		hibernateTemplate.delete(user);
	}

	public List<User> queryAll() {
		// TODO Auto-generated method stub
		return hibernateTemplate.loadAll(User.class);
	}

	public User queryById(int id) {
		
		return hibernateTemplate.get(User.class, id);
	}

	

}
